package com.jshop.search.model;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.List;


@Data
@Document(indexName = "jshop_product", shards = 5, replicas = 1)
public class ProductEntity {
    @Id
    @Field(type = FieldType.Long)
    private Long skuId;

    @Field(type = FieldType.Long)
    private Long spuId;

    @Field(type = FieldType.Text, store = true, analyzer = "ik_smart")
    private String skuTitle;

    @Field(type = FieldType.Keyword)
    private BigDecimal skuPrice;

    @Field(type = FieldType.Keyword, index = false)
    private String skuImg;

    @Field(type = FieldType.Long)
    private Long saleCount;

    @Field(type = FieldType.Boolean)
    private Boolean hasStock;

    @Field(type = FieldType.Long)
    private Long hotScore;

    @Field(type = FieldType.Long)
    private Long brandId;

    @Field(type = FieldType.Long)
    private Long catalogId;

    @Field(type = FieldType.Keyword)
    private String brandName;

    @Field(type = FieldType.Keyword, index = false)
    private String brandImg;

    @Field(type = FieldType.Keyword)
    private String catalogName;

    @Field(type = FieldType.Nested)
    private List<Attrs> attrs;

    @Data
    public static class Attrs {
        @Field(type = FieldType.Long)
        private Long attrId;

        @Field(type = FieldType.Keyword)
        private String attrName;

        @Field(type = FieldType.Keyword)
        private String attrValue;

    }


}
